/*
 * PagosContribuyentesFijosFrame.java
 *
 * Created on 13 de abril de 2008, 11:44 AM
 */
package org.pagos.comercios;


import org.mybeans.Sesion;
 
import org.mybeans.ArregloPagoBeans;
import org.mybeans.ArregloPagoImpuestosBeans;

import org.mybeans.ComerciosBeans;
import org.comercios.registros.ComerciosBusquedaFrame;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.DefaultCellEditor;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

/**
 *
 * @author  avbravo
 */
public class ComerciosArreglosPagoConsultarFrame extends javax.swing.JFrame {

    boolean focoComercio = false;
    String reportSource;
    String reportDest;
    JTextField fieldPago;
    JTextField fieldSaldo;
    JTextField fieldExoneracion;
    Sesion sesion;
    ArregloPagoBeans arregloPagoBeans;
    ArregloPagoImpuestosBeans arregloPagoImpuestosBeans;
    ComerciosBeans comerciosBeans;
    int fila = -1;
    DefaultTableModel modelo;
    private int AnioRecibo;
    private int NumeroMes;
    String IdComercio;
    String TipoId = "comercios";
    private String idRegimen;
    String sql;
    String rowIdRegimen;
    String rowRegimen;
    double rowDeuda;
    int rowMesesMorosos;
    String rowComentario;
    double Pago = 0;
    double Exoneracion = 0;
    double Valor = 0.0;
    double Saldo = 0.0;
    double SaldoAnterior = 0.0;
    int IdRecibo = 0;
    Double TotalPagado = 0.0;
    Double TotalExonerado = 0.0;
    String idExoneracion = "";
    Double Deuda;
    boolean TieneExoneracion = false;
    boolean TieneAlgunRegistroMoroso = false;
    String Estatus;
    int n;
    int paginas;
    double TotalPagoArregloPago = 0.0;
    int IdArregloPago;
    double SaldoActualArregloPago = 0.0;

    /** Creates new form */
    public ComerciosArreglosPagoConsultarFrame() {
        initComponents();
        sesion = new Sesion();
        /*
         * Fondo
         */

         
         
         

        jPanelFondo.setOpaque(false);
        setContentPane(jPanelFondo);
        /*
         * fondo
         */
        arregloPagoBeans = new ArregloPagoBeans();
        arregloPagoImpuestosBeans = new ArregloPagoImpuestosBeans();
        comerciosBeans = new ComerciosBeans();
        java.util.Calendar ca = java.util.Calendar.getInstance();
        java.sql.Date mydate = new java.sql.Date(ca.getTimeInMillis());

        sesion.setTipoId("comercios");

        this.AnioRecibo = ca.get(java.util.Calendar.YEAR);
        NumeroMes = ca.get(java.util.Calendar.MONTH);

        sesion.setAnioRecibo(AnioRecibo);
        sesion.setNumeroMesRecibo(NumeroMes);
        //
        modelo = (DefaultTableModel) jXTable1.getModel();

        // modelo.isCellEditable(1, 1);

        TableColumn columnId = jXTable1.getColumnModel().getColumn(0);
        columnId.setPreferredWidth(130);

        TableColumn columnRegimen = jXTable1.getColumnModel().getColumn(1);
        columnRegimen.setPreferredWidth(130);

        /*
         * Action del menu
         */


    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanelFondo = new javax.swing.JPanel();
        jButtonRegresar = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jTextFieldIdComercio = new javax.swing.JTextField();
        jButtonBuscarComercios = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jTextFieldContribuyente = new javax.swing.JTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        jXTable1 = new org.jdesktop.swingx.JXTable();
        jLabel7 = new javax.swing.JLabel();
        jTextFieldIdArregloPago = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jTextFieldAbonoInicial = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jTextFieldMensualidad = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jTextFieldSaldoActualArregloPago = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jTextFieldComercio = new javax.swing.JTextField();
        jTextFieldCedula = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("CONSULTAR DE ARREGLOS DE PAGOS COMERCIOS");
        addWindowFocusListener(new java.awt.event.WindowFocusListener() {
            public void windowGainedFocus(java.awt.event.WindowEvent evt) {
                formWindowGainedFocus(evt);
            }
            public void windowLostFocus(java.awt.event.WindowEvent evt) {
            }
        });

        jPanelFondo.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanelFondo.setOpaque(false);

        jButtonRegresar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gif/regresar.jpeg"))); // NOI18N
        jButtonRegresar.setToolTipText("Regresar");
        jButtonRegresar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonRegresarActionPerformed(evt);
            }
        });

        jLabel4.setText("Codigo");

        jTextFieldIdComercio.setColumns(35);
        jTextFieldIdComercio.setToolTipText("");
        jTextFieldIdComercio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldIdComercioControlActionPerformed(evt);
            }
        });
        jTextFieldIdComercio.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTextFieldIdComercioKeyPressed(evt);
            }
        });

        jButtonBuscarComercios.setIcon(new javax.swing.ImageIcon(getClass().getResource("/gif/search.png"))); // NOI18N
        jButtonBuscarComercios.setToolTipText("Buscar");
        jButtonBuscarComercios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonBuscarComerciosActionPerformed(evt);
            }
        });

        jLabel5.setText("Contribuyente");

        jTextFieldContribuyente.setColumns(70);
        jTextFieldContribuyente.setEnabled(false);

        jScrollPane2.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
        jScrollPane2.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        jXTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Codigo", "Regimen", "Deuda", "Meses"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Double.class, java.lang.Double.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jXTable1.setOpaque(false);
        jScrollPane2.setViewportView(jXTable1);

        jLabel7.setText("No.Arreglo Pago");

        jTextFieldIdArregloPago.setEditable(false);
        jTextFieldIdArregloPago.setToolTipText("Numero de recibo");
        jTextFieldIdArregloPago.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldIdArregloPagoActionPerformed(evt);
            }
        });

        jLabel10.setText("Abono incial");

        jTextFieldAbonoInicial.setEditable(false);
        jTextFieldAbonoInicial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldAbonoInicialActionPerformed(evt);
            }
        });

        jLabel14.setText("Mensualidad");

        jTextFieldMensualidad.setEditable(false);
        jTextFieldMensualidad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldMensualidadActionPerformed(evt);
            }
        });

        jLabel8.setText("Dueda ");

        jTextFieldSaldoActualArregloPago.setEditable(false);

        jLabel1.setText("Comercio");

        jTextFieldComercio.setEditable(false);

        jTextFieldCedula.setEditable(false);
        jTextFieldCedula.setEnabled(false);

        javax.swing.GroupLayout jPanelFondoLayout = new javax.swing.GroupLayout(jPanelFondo);
        jPanelFondo.setLayout(jPanelFondoLayout);
        jPanelFondoLayout.setHorizontalGroup(
            jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelFondoLayout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 900, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(57, Short.MAX_VALUE))
            .addGroup(jPanelFondoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel7)
                    .addComponent(jLabel5)
                    .addComponent(jLabel1)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addComponent(jTextFieldIdComercio, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButtonBuscarComercios, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButtonRegresar, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(682, 682, 682))
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addComponent(jTextFieldComercio, javax.swing.GroupLayout.PREFERRED_SIZE, 508, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(jPanelFondoLayout.createSequentialGroup()
                        .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanelFondoLayout.createSequentialGroup()
                                .addComponent(jTextFieldCedula, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextFieldContribuyente, javax.swing.GroupLayout.PREFERRED_SIZE, 341, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanelFondoLayout.createSequentialGroup()
                                .addComponent(jTextFieldIdArregloPago, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(48, 48, 48)
                                .addComponent(jLabel10)
                                .addGap(18, 18, 18)
                                .addComponent(jTextFieldAbonoInicial, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jLabel14)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextFieldMensualidad, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextFieldSaldoActualArregloPago, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(87, Short.MAX_VALUE))))
        );
        jPanelFondoLayout.setVerticalGroup(
            jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelFondoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jButtonBuscarComercios)
                        .addComponent(jTextFieldIdComercio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jLabel4)
                    .addComponent(jButtonRegresar))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jTextFieldComercio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel5)
                    .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jTextFieldContribuyente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jTextFieldCedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanelFondoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jTextFieldIdArregloPago, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(jTextFieldAbonoInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14)
                    .addComponent(jTextFieldMensualidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(jTextFieldSaldoActualArregloPago, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelFondo, javax.swing.GroupLayout.PREFERRED_SIZE, 961, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelFondo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jButtonRegresarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonRegresarActionPerformed

    this.dispose();
}//GEN-LAST:event_jButtonRegresarActionPerformed

private void jButtonBuscarComerciosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonBuscarComerciosActionPerformed

    ComerciosBusquedaFrame comerciosBusquedaFrame = new ComerciosBusquedaFrame();
    comerciosBusquedaFrame.setLocationRelativeTo(null);
    comerciosBusquedaFrame.setVisible(true);
    focoComercio = true;
}//GEN-LAST:event_jButtonBuscarComerciosActionPerformed

    private void ActualizarComercios() {
        try {
            LimpiarTable();
            if (CargarComercios() == true) {
                CargarImpuestos();
            }
        } catch (Exception ex) {
         sesion.MostrarMensajeError("Error ", "ActualizarContribuyente()\n " + ex.getMessage().toString());
        }
    }
private void jTextFieldIdComercioKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextFieldIdComercioKeyPressed
}//GEN-LAST:event_jTextFieldIdComercioKeyPressed

private void jTextFieldIdComercioControlActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldIdComercioControlActionPerformed
    ValidarIdComercio();


}//GEN-LAST:event_jTextFieldIdComercioControlActionPerformed

    private void ValidarIdComercio() {
        try {
            LimpiarTable();


            this.IdComercio = this.jTextFieldIdComercio.getText();
            comerciosBeans.setIdComercio(IdComercio);
            if (comerciosBeans.Consultar() == true) {
                if (CargarComercios() == true) {
                    CargarImpuestos();
                }

            }

        } catch (Exception ex) {
            sesion.MostrarMensajeError("Error ", "ValidarCedula()\n " + ex.getMessage().toString());
                    }
    }
private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowGainedFocus
    // TODO add your handling code here:
    try {

        if (focoComercio) {
            ActualizarComercios(); 
        }

        focoComercio = false;
    } catch (Exception ex) {
        sesion.MostrarMensajeError("Error ", "formWindowGainedFocus()\n " + ex.getMessage().toString());
    }
}//GEN-LAST:event_formWindowGainedFocus

private void jTextFieldIdArregloPagoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldIdArregloPagoActionPerformed
}//GEN-LAST:event_jTextFieldIdArregloPagoActionPerformed

private void jTextFieldAbonoInicialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldAbonoInicialActionPerformed
    // TODO add your handling code here:
}//GEN-LAST:event_jTextFieldAbonoInicialActionPerformed

private void jTextFieldMensualidadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldMensualidadActionPerformed
    // TODO add your handling code here:
}//GEN-LAST:event_jTextFieldMensualidadActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new ComerciosArreglosPagoConsultarFrame().setVisible(true);
            }
        });
    }

    /*
     * 
     *verifica si ya se pago la placa para este año 
     * 
     */
    public void CargarImpuestos() {
        try {
            this.IdComercio = jTextFieldIdComercio.getText();
            String SidArregloPago = jTextFieldIdArregloPago.getText();
            if (SidArregloPago == null || SidArregloPago.equals("")) {

                sesion.MostrarMensajeInformacion("Mensaje ", "No hay ningun arreglo de pago seleccionado ");
                jTextFieldIdComercio.requestFocus();
                return;
            }
            /*
             * 
             *buscar la morosidad del comercio
             */
            int idArregloPago = Integer.parseInt(SidArregloPago);
            this.sql = "select arreglopagoimpuestos.*, regimen.regimen " +
                    "from arreglopagoimpuestos, regimen " +
                    " where arreglopagoimpuestos.idmunicipio ='" + sesion.getIdmunicipio() + "'" +
                    " and  arreglopagoimpuestos.idarreglopago='" + idArregloPago + "'" +
                    " and  arreglopagoimpuestos.activo='si'" +
                    " and  arreglopagoimpuestos.idmunicipio = regimen.idmunicipio " +
                    " and  arreglopagoimpuestos.idregimen = regimen.idregimen  " +
                    " and regimen.activo='si'";
            arregloPagoImpuestosBeans.CargarListadoImpuestosArreglosPagos(this.sql);
            /*
             * ListaId , ListaTipoId, ListaIdRegimen
             * ListaRegimen, ListaSaldoActual,
             * ListaNumeroMes
             * 
             */


            CargarArreglo();



            this.jXTable1.setModel(modelo);
            jXTable1.setVisible(true);
            //TableColumn column = jXTable1.getColumnModel().getColumn(4);
            //fieldPago = new JTextField();

            fieldPago.addActionListener(new java.awt.event.ActionListener() {

                public void actionPerformed(java.awt.event.ActionEvent evt) {
//                    jTextFieldPagoActionPerformed(evt);
                }
            });





//            column.setCellEditor(new DefaultCellEditor(fieldPago));

            /*
             * JTextField para el Saldo
             */

            TableColumn columnSaldo = jXTable1.getColumnModel().getColumn(5);
            fieldSaldo = new JTextField();
            fieldSaldo.setEditable(false);
            fieldSaldo.addActionListener(new java.awt.event.ActionListener() {

                public void actionPerformed(java.awt.event.ActionEvent evt) {
//                    jTextFieldSaldoActionPerformed(evt);
                }
            });

            columnSaldo.setCellEditor(new DefaultCellEditor(fieldSaldo));
            /*
             * JTextField para la exoneracion
             */

            TableColumn columnExoneracion = jXTable1.getColumnModel().getColumn(6);
            fieldExoneracion = new JTextField();

            fieldExoneracion.addActionListener(new java.awt.event.ActionListener() {

                public void actionPerformed(java.awt.event.ActionEvent evt) {
//                    jTextFieldExoneracionActionPerformed(evt);
                }
            });
            columnExoneracion.setCellEditor(new DefaultCellEditor(fieldExoneracion));


            TableColumn columnPopup = jXTable1.getColumnModel().getColumn(8);

            this.jXTable1.addMouseListener(new MouseAdapter() {

                public void mouseClicked(MouseEvent e) {
                    if (SwingUtilities.isRightMouseButton(e)) {
//                        popupMenu.show(jXTable1, e.getX(), e.getY());
                    }



                    //if (e.getClickCount()!=1)
                    //  return;


                    fila = jXTable1.rowAtPoint(e.getPoint());
                    int columna = jXTable1.columnAtPoint(e.getPoint());
                    if ((fila > -1) && (columna > -1)) {
                        /*
                        String idRegimen = String.valueOf(jXTable1.getValueAt(fila, 1));
                        String regimen = String.valueOf(jXTable1.getValueAt(fila, 2));
                        String SDeuda = String.valueOf(jXTable1.getValueAt(fila, 3));
                        Valor = Double.parseDouble(SDeuda);
                        String periodoPago = String.valueOf(jXTable1.getValueAt(fila, 4));
                         */
                    }
                }
            });



        } catch (Exception ex) {

            sesion.MostrarMensajeError("Error ", " CargarImpuestos()\n Error: " + ex.getMessage().toString());
        }

    }

    public boolean CargarComercios() {
        try {

            if (comerciosBeans.getActivo().equals("no")) {
                JOptionPane.showMessageDialog(this, "Este registro esta inactivo", "Mensaje", JOptionPane.INFORMATION_MESSAGE);
                return false;
            }
            this.jTextFieldIdComercio.setText(comerciosBeans.getIdComercio());
            this.jTextFieldComercio.setText(comerciosBeans.getComercio());
            this.jTextFieldCedula.setText(comerciosBeans.getCedula());
            this.jTextFieldContribuyente.setText(comerciosBeans.getContribuyente());
            this.IdComercio = this.jTextFieldIdComercio.getText();
            

            arregloPagoBeans.setId(this.IdComercio);
            arregloPagoBeans.setTipoId("comercios");
            arregloPagoBeans.setAnio(this.AnioRecibo);
            if (arregloPagoBeans.Consultar() == false) {
                JOptionPane.showMessageDialog(null, "No tiene un arreglo de pagos registrados.\n Debera seleccionar un comercio con arreglo de pago.", "Mensaje", JOptionPane.INFORMATION_MESSAGE);

                return false;
            }
            jTextFieldIdArregloPago.setText(String.valueOf(arregloPagoBeans.getIdArregloPago()));
            jTextFieldAbonoInicial.setText(String.valueOf(arregloPagoBeans.getAbonoInicial()));
            jTextFieldMensualidad.setText(String.valueOf(arregloPagoBeans.getMensualidad()));
            jTextFieldSaldoActualArregloPago.setText(String.valueOf(arregloPagoBeans.getSaldoActual()));
            this.SaldoActualArregloPago = arregloPagoBeans.getSaldoActual();



            repaint();
            return true;

        } catch (Exception ex) {
            sesion.MostrarMensajeError("Error ", " CargarComercios()\n " + ex.getMessage().toString());
            return false;
        }
    }

    private void Limpiar() {
        try {

            jTextFieldIdArregloPago.setText("");
            jTextFieldAbonoInicial.setText("");
            jTextFieldMensualidad.setText("");
            LimpiarRegimen();
            LimpiarComercios();
            LimpiarTable();
        } catch (Exception ex) {
            sesion.MostrarMensajeError("Error ", " Limpiar()\n " + ex.getMessage().toString());
        }
    }

    public void LimpiarRegimen() {
        //jTextFieldIdRegimen.setText("");
    }

    private void LimpiarComercios() {
        jTextFieldIdComercio.setText("");
        jTextFieldComercio.setText("");
         jTextFieldCedula.setText("");
        jTextFieldContribuyente.setText("");
    }

    /*
     * carga la morosidad,. esta funcion se llama cuando no
     * tiene impuestos y a lo mejor solo le queda pendiente
     * la morosidad
     */
    public void CargarArreglo() {
        try {
            String tipo = "arreglopago";
            for (int m = 0; m <= arregloPagoImpuestosBeans.getNumeroRegistrosLista(); m++) {

                String idRegimen = arregloPagoImpuestosBeans.getListaIdRegimen().get(m);
                String Regimen = arregloPagoImpuestosBeans.getListaRegimen().get(m);
                double Deuda = arregloPagoImpuestosBeans.getListaDeuda().get(m);
                String comentario = arregloPagoImpuestosBeans.getListaComentario().get(m);
                if (comentario == null) {
                    comentario = "";
                }
                int mesesMorosos = arregloPagoImpuestosBeans.getListaMesesMorosos().get(m);
                rowIdRegimen = idRegimen;
                rowRegimen = Regimen;
                rowDeuda = Deuda;
                rowMesesMorosos = mesesMorosos;
                //  rowComentario = comentario;

                AgregarFila();
            }//for

        } catch (Exception ex) {
            sesion.MostrarMensajeError("Error ", " CargarSoloMorosidad()\n " + ex.getMessage().toString());
        }
    }

    /*
     * agregar fila
     * 
     */
    private void LimpiarTable() {
        try {
            //limpiar  el jXTable
            jTextFieldIdArregloPago.setText("");
            jTextFieldAbonoInicial.setText("");
            jTextFieldMensualidad.setText("");
            boolean control = false;
            while (control == false) {
                int n = jXTable1.getRowCount();
                //System.out.println("n" + n);
                if (n <= 0) {
                    control = true;
                } else {
                    modelo.removeRow(0);
                }

            }//while
        } catch (Exception ex) {
            sesion.MostrarMensajeError("Error ", " LimpiarTable()\n " + ex.getMessage().toString());
        }
    }

    /*
     *
     *Cargar
     *
     */
    private void AgregarFila() {
        try {
            Object[] filas = new Object[4]; // Hay tres columnas en la tabla


            filas[0] = rowIdRegimen;
            filas[1] = rowRegimen;
            filas[2] = rowDeuda;
            filas[3] = rowMesesMorosos;
            //  filas[4] = rowComentario;

            modelo.addRow(filas);
        } catch (Exception ex) {
            sesion.MostrarMensajeError("Error ", " AgregarFila()\n " + ex.getMessage().toString());
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonBuscarComercios;
    private javax.swing.JButton jButtonRegresar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanelFondo;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField jTextFieldAbonoInicial;
    private javax.swing.JTextField jTextFieldCedula;
    private javax.swing.JTextField jTextFieldComercio;
    private javax.swing.JTextField jTextFieldContribuyente;
    private javax.swing.JTextField jTextFieldIdArregloPago;
    private javax.swing.JTextField jTextFieldIdComercio;
    private javax.swing.JTextField jTextFieldMensualidad;
    private javax.swing.JTextField jTextFieldSaldoActualArregloPago;
    private org.jdesktop.swingx.JXTable jXTable1;
    // End of variables declaration//GEN-END:variables
}
